function [bnet trainData] = getNet(dataset, detectStruct, depletedRowsRatio, depletedColsRatio)
    %some general stuff
    bnet=nan;
    dag=nan;
    trainData=nan;
    names=nan;
    node_sizes=nan;
    N=0;
    if (dataset=='cancer')
        display('cancer');
        N = 12;
        names = {'SMOKING', 'YELLOW_FINGERS', 'ANXIETY', 'PEER_PRESSURE', ...
              'GENETICS', 'ATTENTION_DISORDER', 'BORN_ON_EVEN_DAY', ...
              'CAR_ACCIDENT', 'FATIGUE', 'ALLERGY', 'COUGHING', 'CANCER'};
        dag = zeros(N,N);
        SMOKING = 1;
        YELLOW_FINGERS = 2;
        ANXIETY = 3;
        PEER_PRESSURE = 4;
        GENETICS = 5;
        ATTENTION_DISORDER = 6;
        BORN_ON_EVEN_DAY = 7;
        CAR_ACCIDENT = 8;
        FATIGUE = 9;
        ALLERGY = 10;
        COUGHING = 11;
        CANCER = 12;

        dag(CANCER,[COUGHING ATTENTION_DISORDER FATIGUE]) = 1;
        dag([ATTENTION_DISORDER, FATIGUE], CAR_ACCIDENT) = 1;
        dag([PEER_PRESSURE ANXIETY],SMOKING)=1;
        dag(SMOKING,[YELLOW_FINGERS CANCER COUGHING])=1;
        dag([GENETICS ALLERGY SMOKING BORN_ON_EVEN_DAY], CANCER)=1;
        dag(GENETICS, ALLERGY)=1;
        dag(COUGHING, FATIGUE)=1;

        %define a vector of node sizes (all nodes discrete and binary)
        %discrete_nodes= 1:N;
        node_sizes=2*ones(1,N);

        %observed nodes? here:
        %observed_nodes=[];
 
        data=load('Lung_Cancer.data');
        labels = load('Lung_Cancer.targets');
        trainData = [data, labels];
        trainData=trainData+1;
        trainData(trainData==0)=1;
        display('ending the branch');
    elseif(dataset=='diabetes')
        display('diabetes');    
    else
        display('default - car');
    end;
    
    if(detectStruct==2)
        display('searching for structure');
        structs = learn_struct_mcmc(trainData',node_sizes);
        scores=score_dags(trainData',node_sizes,structs);
        display('highest score');
        [highscore index]=max(scores);
        display(highscore);
        dag=structs{index};
        display('found structure');
        %draw_graph(dag, names);
    end;
    
    [dag trainData names node_sizes] = fixTopology(dag, trainData, names, node_sizes);

    draw_graph(dag, names);
    
    %make the bayesian net
    display('creating net');
    bnet=mk_bnet(dag, node_sizes, ...
            'names', names);

    ncases = size(data, 1);
    cases=cell(12, ncases);
    cases(1:12,:)=num2cell(trainData');

    
    %deplete the data a little bit
    recordsToDeplete=randperm(size(cases,2));
    a=randperm(size(cases,2));
    a=a(1:depletedRowsRatio*size(cases,2));
    for(i=1:size(a,2))
        for(j=1:size(cases,1))
            if(rand<depletedColsRatio)
                cases{j,i}=[];
            end;
        end;
    end;
    
    seed = 0;
    rand('state', seed);
    for i=1:N
        bnet.CPD{i} = tabular_CPD(bnet, i);
    end;
    if(depletedRowsRatio*depletedColsRatio==0)
        bnet = learn_params(bnet, cases);
    else
        engine = jtree_inf_engine(bnet);
        max_iter = 10;
        bnet = learn_params_em(engine, cases, max_iter);
    end;
end